<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="Associar Revisores à Submissão"></h:outputText>
            <br />
            <h3>Submissão: #{revisorController.submissao}</h3>
        </ui:define>
        <ui:define name="body">
            <div style="float: left; width: 50%">
            <h:form styleClass="jsfcrud_list_form">
                <h:panelGroup id="messagePanel" layout="block">
                    <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
                </h:panelGroup>
                <p>
                    <h:outputText value="Pesquisa: " /><br/>
                    <h:inputText id="procura" value="#{revisorController.procura}" />
                    <h:outputText value=" "/>
                    <h:selectOneMenu id="tipos" value="#{revisorController.tipoProcuraSelecionada}">
                        <f:selectItems value="#{revisorController.tipoProcura}" />
                    </h:selectOneMenu>
                    <h:outputText value=" "/>
                    <h:commandButton id="btn_pesquisar" action="#{revisorController.prepareList()}" value="Pesquisar" />
                </p>
                <h:outputText escape="false" value="Não existem revisores" rendered="#{revisorController.items.rowCount == 0}"/>
                <h:panelGroup rendered="#{revisorController.items.rowCount > 0}">
                    <h:outputText value="#{revisorController.pagination.pageFirstItem + 1}..#{revisorController.pagination.pageLastItem + 1}/#{revisorController.pagination.itemsCount}"/>&nbsp;
                    <h:commandLink action="#{revisorController.previous}" value="Anterior #{revisorController.pagination.pageSize}" rendered="#{revisorController.pagination.hasPreviousPage}"/>&nbsp;
                    <h:commandLink action="#{revisorController.next}" value="Seguinte #{revisorController.pagination.pageSize}" rendered="#{revisorController.pagination.hasNextPage}"/>&nbsp;
                    <h:dataTable value="#{revisorController.items}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Username"/>
                            </f:facet>
                            <h:outputText value="#{item.username}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Primeiro Nome"/>
                            </f:facet>
                            <h:outputText value="#{item.pNome}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Ultimo Nome"/>
                            </f:facet>
                            <h:outputText value="#{item.uNome}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="E-Mail"/>
                            </f:facet>
                            <h:outputText value="#{item.email}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Empresa"/>
                            </f:facet>
                            <h:outputText value="#{item.empresa}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="&nbsp;"/>
                            </f:facet>
                            <h:commandLink action="#{revisorController.adicionarRevisor()}" value="Adicionar"/>
                        </h:column>
                    </h:dataTable>
                </h:panelGroup>
                <br />
                <br />
                <h:commandLink value="Voltar ao Evento" action="/evento/View" immediate="true" />
            </h:form>
            </div>
            <div style="float: right; width: 50%">
            <h1>Revisores da Submissão</h1>
            <h:form styleClass="jsfcrud_list_form">
                <h:outputText escape="false" value="Nenhum revisor adicionado!" rendered="#{revisoreController.revisores.rowCount == 0}"/>
                <h:panelGroup rendered="#{revisorController.revisores.rowCount > 0}">
                    <h:dataTable value="#{revisorController.revisores}" var="revisor" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Username"/>
                            </f:facet>
                            <h:outputText value="#{revisor.username}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Primeiro Nome"/>
                            </f:facet>
                            <h:outputText value="#{revisor.pNome}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Ultimo Nome"/>
                            </f:facet>
                            <h:outputText value="#{revisor.uNome}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="E-Mail"/>
                            </f:facet>
                            <h:outputText value="#{revisor.email}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Empresa" />
                            </f:facet>
                            <h:outputText value="#{revisor.empresa}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="&nbsp;"/>
                            </f:facet>
                            <h:commandLink action="#{revisorController.retirarRevisor()}" rendered="#{revisorController.isStarted(revisor.username)}" value="Retirar"/>
                        </h:column>
                    </h:dataTable>
                </h:panelGroup>
            </h:form>
            </div>
        </ui:define>
    </ui:composition>

</html>
